package com.qf.mq;

import com.qf.config.DeadLetterConfig;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class DeadListener {

    /*@RabbitListener(queues = DeadLetterConfig.NORMAL_QUEUE)
    public void normalQueueConsume(String msg , Channel channel, Message message) throws IOException {
        System.out.println("普通队列接收到消息:" + msg);
        System.out.println("拒绝这个消息");
        channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,false);
    }*/

    @RabbitListener(queues = DeadLetterConfig.DEAD_QUEUE)
    public void deadQueueConsume(String msg , Channel channel, Message message) throws IOException {
        System.out.println("收消息时间:" + System.currentTimeMillis());
        System.out.println("死信队列接收到死信:" + msg);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }


}
